import React from 'react'

import {WeaLocaleProvider} from 'ecCom'
const getLabel = WeaLocaleProvider.getLabel;
import AddExtend from "./addExtend";
import SettingExtend from "./settingExtend";

export default class SettingProxy extends React.Component{


    onGetColsAfterHandler = (columns)=>{
        if(columns.length == 2){
            columns[0].width = '30%'
            columns[1].width = '40%'
        }

        let temp = {
            title: getLabel(74, '图片'),
            key: 'img',
            width: '30%',
            render: (text,record)=>{
                return (
                    <img className='setting-table-column-img' src={record.img}/>
                )
            }
        }
        columns.splice(1,0,temp)
    }

    onGetDataAfterHandler = (datas)=>{
        let items = this.props.data.itemsForSetting
        for(let i in datas){
            if(datas.hasOwnProperty(i)){
                datas[i].url = items[i].setting.url
                datas[i].img = items[i].setting.img
            }
        }
    }

    render(){
        const {Setting} = this.props

        return (
            <Setting ecId={`${this && this.props && this.props.ecId || ''}_Setting@uay5b6`} ref='Setting' {...this.props} onGetColsAfterHandler={this.onGetColsAfterHandler} onGetDataAfterHandler={this.onGetDataAfterHandler} AddExtend={AddExtend} SettingExtend={SettingExtend}></Setting>
        )

    }

}